import request from '@/config/axios'

export interface EnergyStatisticsVO {
  totalEnergy: number
  currentPower: number
  warningCount: number
  energySavingRate: number
}

export interface EnergyTrendVO {
  time: string
  totalEnergy: number
  peakEnergy: number
  baseline: number
}

export interface EnergyDistributionVO {
  name: string
  value: number
}

export interface WarningRecordVO {
  id: number
  time: string
  location: string
  type: string
  value: string
  status: string
}

// 获取能耗统计数据
export const getEnergyStatistics = () => {
  return request.get<EnergyStatisticsVO>('/energy/dashboard/statistics')
}

// 获取能耗趋势数据
export const getEnergyTrend = (params: { type: 'day' | 'week' | 'month' }) => {
  return request.get<EnergyTrendVO[]>('/energy/dashboard/trend', { params })
}

// 获取能耗分布数据
export const getEnergyDistribution = () => {
  return request.get<EnergyDistributionVO[]>('/energy/dashboard/distribution')
}

// 获取预警记录
export const getWarningRecords = (params: { pageNo: number; pageSize: number }) => {
  return request.get<WarningRecordVO[]>('/energy/dashboard/warnings', { params })
}
